Conventional electronic control units (ECUs) to be installed in, for example, vehicles are configured to manage a plurality of tasks and execute the tasks in a time-sharing mode in accordance with an embedded operating system (OS). As such embedded operating systems, a Real-Time Operating system (RTOS) is normally used. The RTOS is operative to schedule for wakeup and running of a plurality of tasks in accordance with respectively corresponding determined priorities. As such real-time operating systems, an OSEK/VDX OS has been well known.
Upon a plurality of tasks being scheduled for execution by a microprocessor, when an interrupt fires to switch from one to another task, the microprocessor is operative to save context data identifying the state of each register being used by execution of a task in a stack previously prepared in a RAM (Random Access Memory). In addition, when a function is called, a microprocessor is operative to save context data indicative of the state of each register in a stack (stack space) previously prepared in a RAM.
As set forth above, stacks play an important role as memory area for storing a result of processes executed by a microprocessor. For this reason, in order to develop an electronic system for controlling targets, such as in-vehicle devices, it is especially important to allocate a required memory space to a stack, and to design a plurality of software modules so as to prevent stack overflow.
In conventional electronic system developments, therefore, an amount of space in a stack to be used for each module of software is estimated, and the total amount of space in the stack to be used for all of the software modules is calculated by desk calculation. This can estimate the size of a stack required for all of the software modules to be executed by a microcomputer.
However, even one nest and the number of arguments to be used in one or more functions of each of the software modules can dynamically change an amount of space in a stack to be required for a corresponding one of the software modules. Moreover, the frequency of occurrence of interrupts also can dynamically change an amount of space in a stack to be used for a corresponding one of the software modules.
As described above, in ECUs designed to schedule a plurality of tasks for execution in a multitask OS, it may be difficult to properly estimate, using desk calculation, the size of a stack required for each of the software modules to be executed by a microcomputer.
For this reason, in order to properly check the size of a space in a stack required for each of program tasks to be executed by a microcomputer, a conventional electronic system, which is disclosed in Japanese Unexamined Patent Publication No. H03-278135, has installed therein functions of:
estimating an amount of space in a stack to be actually used by a next task each time of the occurrence of switching from a current task to the next task to determine whether the estimated amount of space in the stack exceeds the previous maximum amount of space therein; and
updating the previous maximum amount of space in the stack to the estimated amount of space in the stack to be used by the next task when it is determined that the estimated amount of space in the stack exceeds the previous maximum amount of space therein.
In addition, a conventional computer system, which is disclosed in Japanese Unexamined Patent Publication No. 2000-187601, is configured to:
monitor the movement of a stack pointer pointing to the most recently referenced location on a stack to another location thereon upon switching of a task or execution of a load module; and
estimate an amount of space in the stack to be required for a task to be switched or the load module based on the monitored movement of the stack pointer.
In the latter patent Publication, the computer system is designed to, whenever the stack pointer moves, estimate an amount of space in the stack to be required for a task to be switched or a load module based on the monitored movement of the stack pointer. This may cause the overhead of the estimating process to increase, in other words, cause the resources of the computer system to be excessively utilized for the estimating process. The increasing of the overhead may cause an unwanted decrease in the operation rate of the computer system for execution of tasks previously scheduled therefor each time of the movement of the stack pointer.
In addition, in the former and latter patent Publications, if real-time control that requires severe execution-timing restrictions is needed to be executed in vehicle control, for example, it may be difficult to estimate an amount of space in a stack to be used by a next task to be switched each time of the occurrence of switching from a current task to the next task.